<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div>
      <span id="h">00</span>
      <span>:</span>
      <span id="m">00</span>
      <span>:</span>
      <span id="s">00</span>
    </div>
    <script>
      /*
        1. 制作跟随系统的时钟
        2. 加上前导零
        3. 转数字图片
      */
      setInterval(() => {
        const d = new Date();
        const dH = d.getHours() < 10 ? "0" + d.getHours() : d.getHours();
        const dM = d.getMinutes() < 10 ? "0" + d.getMinutes() : d.getMinutes();
        const dS = d.getSeconds() < 10 ? "0" + d.getSeconds() : d.getSeconds();
        const str = String(dH)
          .split("")
          .map((el) => {
            return `<img src="./imgs/countdown${el}.png">`;
          })
          .join("");
        console.log(str);
      }, 1000);
    </script>
  </body>
</html>
